#include <zmq.hpp>
#include <iostream>
#include <chrono>
#include <thread>
#include <cstring>

int main() {
    zmq::context_t context{1};
    zmq::socket_t socket{context, zmq::socket_type::push};
    socket.bind("tcp://*:5555");

    while (true) {
        // 获取当前时间作为时间戳
        auto start_time = std::chrono::high_resolution_clock::now();
        auto timestamp = std::chrono::duration_cast<std::chrono::microseconds>(start_time.time_since_epoch()).count();

        // 将时间戳转换为字符串
        std::string message = std::to_string(timestamp);

        // 发送消息
        zmq::message_t zmq_message(message.data(), message.size());
        socket.send(zmq_message, zmq::send_flags::none);

        std::this_thread::sleep_for(std::chrono::seconds(1));
    }

    return 0;
}
